package com.czy.ekp.gen;

import freemarker.template.Template;

import java.util.HashMap;
import java.util.Map;

public class SqlTemplateGenerator extends TemplateCodeGenerator{



    public SqlTemplateGenerator(Template template) {
        super(template);
    }

    @Override
    public Map generateParameterMap(ModuleVo moduleVo) {

        HashMap params = new HashMap();
        for(FieldVo field : moduleVo.getFields()){
            field.setType(GenConsts.TO_DB_TYPES.get(field.getType()));
        }

        moduleVo.getFields().remove(moduleVo.getKeyField());

        params.put("moduleName", moduleVo.getModuleName());
        params.put("sqlTable", GenConsts.SQL_TABLE);
        params.put("key", moduleVo.getKeyField().getName());
        params.put("fields", moduleVo.getFields());

        return params;
    }
}
